import * as types from "../mutationTypes"
import {HOME} from "../../assets/js/global"

const state = {
  activeTab: HOME,
  cachedTabs:[],
  isDropDown: false
};

const mutations = {
  [types.SET_ACTIVE_TAB](state, label) {
    state.activeTab = label;
  },
  [types.ADD_CACHED_TAB](state, menu) {
    state.cachedTabs.push(menu);
  },
  [types.REMOVE_CACHED_TAB](state, index) {
    state.cachedTabs.splice(index, 1);
  },
  [types.CLEAR_CACHED_TABS](state) {
    state.cachedTabs = []
  },
  [types.ONLY_KEEP_ACTIVE_TAB](state) {
    state.cachedTabs = state.cachedTabs.filter(item=>item.label === state.activeTab);
  },
  [types.SET_TAB_BAR_DROP_DOWN](state, isDropDown) {
    state.isDropDown = isDropDown;
  }
};

export default {
  state,
  mutations
}



// WEBPACK FOOTER //
// ./src/store/modules/Tab.js